home *** CD-ROM | disk | FTP | other *** search
/ IRIX Base Documentation 2002 November / SGI IRIX Base Documentation 2002 November.iso / usr / share / catman / u_man / cat1 / perldebug.z / perldebug
Encoding:
Text File  |  2002-10-03  |  51.4 KB  |  1,321 lines

  1.  
  2.  
  3.  
  4. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  5.  
  6.  
  7.  
  8. NNNNAAAAMMMMEEEE
  9.      perldebug - Perl debugging
  10.  
  11. DDDDEEEESSSSCCCCRRRRIIIIPPPPTTTTIIIIOOOONNNN
  12.      First of all, have you tried using the ----wwww switch?
  13.  
  14. TTTThhhheeee PPPPeeeerrrrllll DDDDeeeebbbbuuuuggggggggeeeerrrr
  15.      "As soon as we started programming, we found to our surprise that it
  16.      wasn't as easy to get programs right as we had thought.  Debugging had to
  17.      be discovered.  I can remember the exact instant when I realized that a
  18.      large part of my life from then on was going to be spent in finding
  19.      mistakes in my own programs."
  20.  
  21.        --_M_a_u_r_i_c_e _W_i_l_k_e_s, _1_9_4_9
  22.  
  23.      If you invoke Perl with the ----dddd switch, your script runs under the Perl
  24.      source debugger.  This works like an interactive Perl environment,
  25.      prompting for debugger commands that let you examine source code, set
  26.      breakpoints, get stack backtraces, change the values of variables, etc.
  27.      This is so convenient that you often fire up the debugger all by itself
  28.      just to test out Perl constructs interactively to see what they do.  For
  29.      example:
  30.  
  31.          perl -d -e 42
  32.  
  33.      In Perl, the debugger is not a separate program as it usually is in the
  34.      typical compiled environment.  Instead, the ----dddd flag tells the compiler to
  35.      insert source information into the parse trees it's about to hand off to
  36.      the interpreter.  That means your code must first compile correctly for
  37.      the debugger to work on it.  Then when the interpreter starts up, it
  38.      preloads a Perl library file containing the debugger itself.
  39.  
  40.      The program will halt _r_i_g_h_t _b_e_f_o_r_e the first run-time executable
  41.      statement (but see below regarding compile-time statements) and ask you
  42.      to enter a debugger command.  Contrary to popular expectations, whenever
  43.      the debugger halts and shows you a line of code, it always displays the
  44.      line it's _a_b_o_u_t to execute, rather than the one it has just executed.
  45.  
  46.      Any command not recognized by the debugger is directly executed (eval'd)
  47.      as Perl code in the current package.  (The debugger uses the DB package
  48.      for its own state information.)
  49.  
  50.      Leading white space before a command would cause the debugger to think
  51.      it's _N_O_T a debugger command but for Perl, so be careful not to do that.
  52.  
  53.      DDDDeeeebbbbuuuuggggggggeeeerrrr CCCCoooommmmmmmmaaaannnnddddssss
  54.  
  55.      The debugger understands the following commands:
  56.  
  57.      h [command] Prints out a help message.
  58.  
  59.                  If you supply another debugger command as an argument to the
  60.  
  61.  
  62.  
  63.                                                                         PPPPaaaaggggeeee 1111
  64.  
  65.  
  66.  
  67.  
  68.  
  69.  
  70. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  71.  
  72.  
  73.  
  74.                  h command, it prints out the description for just that
  75.                  command.  The special argument of h h produces a more compact
  76.                  help listing, designed to fit together on one screen.
  77.  
  78.                  If the output of the h command (or any command, for that
  79.                  matter) scrolls past your screen, either precede the command
  80.                  with a leading pipe symbol so it's run through your pager, as
  81.                  in
  82.  
  83.                      DB> |h
  84.  
  85.                  You may change the pager which is used via O pager=...
  86.                  command.
  87.  
  88.      p expr      Same as print {$DB::OUT} expr in the current package.  In
  89.                  particular, because this is just Perl's own pppprrrriiiinnnntttt function,
  90.                  this means that nested data structures and objects are not
  91.                  dumped, unlike with the x command.
  92.  
  93.                  The DB::OUT filehandle is opened to /_d_e_v/_t_t_y, regardless of
  94.                  where STDOUT may be redirected to.
  95.  
  96.      x expr      Evaluates its expression in list context and dumps out the
  97.                  result in a pretty-printed fashion.  Nested data structures
  98.                  are printed out recursively, unlike the print function.
  99.  
  100.                  The details of printout are governed by multiple Options.
  101.  
  102.      V [pkg [vars]]
  103.                  Display all (or some) variables in package (defaulting to the
  104.                  main package) using a data pretty-printer (hashes show their
  105.                  keys and values so you see what's what, control characters
  106.                  are made printable, etc.).  Make sure you don't put the type
  107.                  specifier (like $) there, just the symbol names, like this:
  108.  
  109.                      V DB filename line
  110.  
  111.                  Use ~pattern and !pattern for positive and negative regexps.
  112.  
  113.                  Nested data structures are printed out in a legible fashion,
  114.                  unlike the print function.
  115.  
  116.                  The details of printout are governed by multiple Options.
  117.  
  118.      X [vars]    Same as V currentpackage [vars].
  119.  
  120.      T           Produce a stack backtrace.  See below for details on its
  121.                  output.
  122.  
  123.      s [expr]    Single step.  Executes until it reaches the beginning of
  124.                  another statement, descending into subroutine calls.  If an
  125.                  expression is supplied that includes function calls, it too
  126.  
  127.  
  128.  
  129.                                                                         PPPPaaaaggggeeee 2222
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  137.  
  138.  
  139.  
  140.                  will be single-stepped.
  141.  
  142.      n [expr]    Next.  Executes over subroutine calls, until it reaches the
  143.                  beginning of the next statement.  If an expression is
  144.                  supplied that includes function calls, those functions will
  145.                  be executed with stops before each statement.
  146.  
  147.      <CR>        Repeat last n or s command.
  148.  
  149.      c [line|sub]
  150.                  Continue, optionally inserting a one-time-only breakpoint at
  151.                  the specified line or subroutine.
  152.  
  153.      l           List next window of lines.
  154.  
  155.      l min+incr  List incr+1 lines starting at min.
  156.  
  157.      l min-max   List lines min through max.  l - is synonymous to -.
  158.  
  159.      l line      List a single line.
  160.  
  161.      l subname   List first window of lines from subroutine.
  162.  
  163.      -           List previous window of lines.
  164.  
  165.      w [line]    List window (a few lines) around the current line.
  166.  
  167.      .           Return debugger pointer to the last-executed line and print
  168.                  it out.
  169.  
  170.      f filename  Switch to viewing a different file or eval statement.  If
  171.                  filename is not a full filename as found in values of %INC,
  172.                  it is considered as a regexp.
  173.  
  174.      /pattern/   Search forwards for pattern; final / is optional.
  175.  
  176.      ?pattern?   Search backwards for pattern; final ? is optional.
  177.  
  178.      L           List all breakpoints and actions.
  179.  
  180.      S [[!]pattern]
  181.                  List subroutine names [not] matching pattern.
  182.  
  183.      t           Toggle trace mode (see also AutoTrace Option).
  184.  
  185.      t expr      Trace through execution of expr.  For example:
  186.  
  187.                   $ perl -de 42
  188.                   Stack dump during die enabled outside of evals.
  189.  
  190.                   Loading DB routines from perl5db.pl patch level 0.94
  191.                   Emacs support available.
  192.  
  193.  
  194.  
  195.                                                                         PPPPaaaaggggeeee 3333
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  203.  
  204.  
  205.  
  206.                   Enter h or `h h' for help.
  207.  
  208.                   main::(-e:1):   0
  209.                     DB<1> sub foo { 14 }
  210.  
  211.                     DB<2> sub bar { 3 }
  212.  
  213.                     DB<3> t print foo() * bar()
  214.                   main::((eval 172):3):   print foo() + bar();
  215.                   main::foo((eval 168):2):
  216.                   main::bar((eval 170):2):
  217.                   42
  218.  
  219.                  or, with the Option frame=2 set,
  220.  
  221.                     DB<4> O f=2
  222.                                  frame = '2'
  223.                     DB<5> t print foo() * bar()
  224.                   3:      foo() * bar()
  225.                   entering main::foo
  226.                    2:     sub foo { 14 };
  227.                   exited main::foo
  228.                   entering main::bar
  229.                    2:     sub bar { 3 };
  230.                   exited main::bar
  231.                   42
  232.  
  233.  
  234.      b [line] [condition]
  235.                  Set a breakpoint.  If line is omitted, sets a breakpoint on
  236.                  the line that is about to be executed.  If a condition is
  237.                  specified, it's evaluated each time the statement is reached
  238.                  and a breakpoint is taken only if the condition is true.
  239.                  Breakpoints may be set on only lines that begin an executable
  240.                  statement.  Conditions don't use iiiiffff:
  241.  
  242.                      b 237 $x > 30
  243.                      b 237 ++$count237 < 11
  244.                      b 33 /pattern/i
  245.  
  246.  
  247.      b subname [condition]
  248.                  Set a breakpoint at the first line of the named subroutine.
  249.  
  250.      b postpone subname [condition]
  251.                  Set breakpoint at first line of subroutine after it is
  252.                  compiled.
  253.  
  254.      b load filename
  255.                  Set breakpoint at the first executed line of the file.
  256.                  Filename should be a full name as found in values of %INC.
  257.  
  258.  
  259.  
  260.  
  261.                                                                         PPPPaaaaggggeeee 4444
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  269.  
  270.  
  271.  
  272.      b compile subname
  273.                  Sets breakpoint at the first statement executed after the
  274.                  subroutine is compiled.
  275.  
  276.      d [line]    Delete a breakpoint at the specified line.  If line is
  277.                  omitted, deletes the breakpoint on the line that is about to
  278.                  be executed.
  279.  
  280.      D           Delete all installed breakpoints.
  281.  
  282.      a [line] command
  283.                  Set an action to be done before the line is executed.  The
  284.                  sequence of steps taken by the debugger is
  285.  
  286.                    1. check for a breakpoint at this line
  287.                    2. print the line if necessary (tracing)
  288.                    3. do any actions associated with that line
  289.                    4. prompt user if at a breakpoint or in single-step
  290.                    5. evaluate line
  291.  
  292.                  For example, this will print out $foo every time line 53 is
  293.                  passed:
  294.  
  295.                      a 53 print "DB FOUND $foo\n"
  296.  
  297.  
  298.      A           Delete all installed actions.
  299.  
  300.      O [opt[=val]] [op'val' [opt?]...
  301.                  Set or query values of options.  val defaults to 1.  opt can
  302.                  be abbreviated.  Several options can be listed.
  303.  
  304.      recallCommand, ShellBang
  305.                              The characters used to recall command or spawn
  306.                              shell.  By default, these are both set to !.
  307.  
  308.      pager                   Program to use for output of pager-piped commands
  309.                              (those beginning with a | character.)  By
  310.                              default, $ENV{PAGER} will be used.
  311.  
  312.      tkRunning               Run Tk while prompting (with ReadLine).
  313.  
  314.      signalLevel, warnLevel, dieLevel
  315.                              Level of verbosity.  By default the debugger is
  316.                              in a sane verbose mode, thus it will print
  317.                              backtraces on all the warnings and die-messages
  318.                              which are going to be printed out, and will print
  319.                              a message when interesting uncaught signals
  320.                              arrive.
  321.  
  322.                              To disable this behaviour, set these values to 0.
  323.                              If dieLevel is 2, then the messages which will be
  324.  
  325.  
  326.  
  327.                                                                         PPPPaaaaggggeeee 5555
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  335.  
  336.  
  337.  
  338.                              caught by surrounding eval are also printed.
  339.  
  340.      AutoTrace               Trace mode (similar to t command, but can be put
  341.                              into PERLDB_OPTS).
  342.  
  343.      LineInfo                File or pipe to print line number info to.  If it
  344.                              is a pipe (say, |visual_perl_db), then a short,
  345.                              "emacs like" message is used.
  346.  
  347.      inhibit_exit            If 0, allows _s_t_e_p_p_i_n_g _o_f_f the end of the script.
  348.  
  349.      PrintRet                affects printing of return value after r command.
  350.  
  351.      ornaments               affects screen appearance of the command line
  352.                              (see the _T_e_r_m::_R_e_a_d_L_i_n_e manpage).
  353.  
  354.      frame                   affects printing messages on entry and exit from
  355.                              subroutines.  If frame & 2 is false, messages are
  356.                              printed on entry only. (Printing on exit may be
  357.                              useful if _i_n_t_e_r(di)spersed with other messages.)
  358.  
  359.                              If frame & 4, arguments to functions are printed
  360.                              as well as the context and caller info.  If frame
  361.                              & 8, overloaded stringify and tied FETCH are
  362.                              enabled on the printed arguments. If frame & 16,
  363.                              the return value from the subroutine is printed
  364.                              as well.
  365.  
  366.                              The length at which the argument list is
  367.                              truncated is governed by the next option:
  368.  
  369.      maxTraceLen             length at which the argument list is truncated
  370.                              when frame option's bit 4 is set.
  371.  
  372.                              The following options affect what happens with V,
  373.                              X, and x commands:
  374.  
  375.      arrayDepth, hashDepth   Print only first N elements ('' for all).
  376.  
  377.      compactDump, veryCompact
  378.                              Change style of array and hash dump.  If
  379.                              compactDump, short array may be printed on one
  380.                              line.
  381.  
  382.      globPrint               Whether to print contents of globs.
  383.  
  384.      DumpDBFiles             Dump arrays holding debugged files.
  385.  
  386.      DumpPackages            Dump symbol tables of packages.
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.                                                                         PPPPaaaaggggeeee 6666
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  401.  
  402.  
  403.  
  404.      quote, HighBit, undefPrint
  405.                              Change style of string dump.  Default value of
  406.                              quote is auto, one can enable either double-
  407.                              quotish dump, or single-quotish by setting it to
  408.                              " or '.  By default, characters with high bit set
  409.                              are printed _a_s _i_s.
  410.  
  411.      UsageOnly               _v_e_r_y rudimentally per-package memory usage dump.
  412.                              Calculates total size of strings in variables in
  413.                              the package.
  414.  
  415.                              During startup options are initialized from
  416.                              $ENV{PERLDB_OPTS}.  You can put additional
  417.                              initialization options TTY, noTTY, ReadLine, and
  418.                              NonStop there.
  419.  
  420.                              Example rc file:
  421.  
  422.                                &parse_options("NonStop=1 LineInfo=db.out AutoTrace");
  423.  
  424.                              The script will run without human intervention,
  425.                              putting trace information into the file _d_b._o_u_t.
  426.                              (If you interrupt it, you would better reset
  427.                              LineInfo to something "interactive"!)
  428.  
  429.      TTY                     The TTY to use for debugging I/O.
  430.  
  431.      noTTY                   If set, goes in NonStop mode, and would not
  432.                              connect to a TTY.  If interrupt (or if control
  433.                              goes to debugger via explicit setting of
  434.                              $DB::signal or $DB::single from the Perl script),
  435.                              connects to a TTY specified by the TTY option at
  436.                              startup, or to a TTY found at runtime using
  437.                              Term::Rendezvous module of your choice.
  438.  
  439.                              This module should implement a method new which
  440.                              returns an object with two methods: IN and OUT,
  441.                              returning two filehandles to use for debugging
  442.                              input and output correspondingly.  Method new may
  443.                              inspect an argument which is a value of
  444.                              $ENV{PERLDB_NOTTY} at startup, or is
  445.                              "/tmp/perldbtty$$" otherwise.
  446.  
  447.      ReadLine                If false, readline support in debugger is
  448.                              disabled, so you can debug ReadLine applications.
  449.  
  450.      NonStop                 If set, debugger goes into noninteractive mode
  451.                              until interrupted, or programmatically by setting
  452.                              $DB::signal or $DB::single.
  453.  
  454.                              Here's an example of using the $ENV{PERLDB_OPTS}
  455.                              variable:
  456.  
  457.  
  458.  
  459.                                                                         PPPPaaaaggggeeee 7777
  460.  
  461.  
  462.  
  463.  
  464.  
  465.  
  466. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  467.  
  468.  
  469.  
  470.                                $ PERLDB_OPTS="N f=2" perl -d myprogram
  471.  
  472.                              will run the script myprogram without human
  473.                              intervention, printing out the call tree with
  474.                              entry and exit points.  Note that N f=2 is
  475.                              equivalent to NonStop=1 frame=2.  Note also that
  476.                              at the moment when this documentation was written
  477.                              all the options to the debugger could be uniquely
  478.                              abbreviated by the first letter (with exception
  479.                              of Dump* options).
  480.  
  481.                              Other examples may include
  482.  
  483.                                $ PERLDB_OPTS="N f A L=listing" perl -d myprogram
  484.  
  485.                              - runs script noninteractively, printing info on
  486.                              each entry into a subroutine and each executed
  487.                              line into the file _l_i_s_t_i_n_g. (If you interrupt it,
  488.                              you would better reset LineInfo to something
  489.                              "interactive"!)
  490.  
  491.                                $ env "PERLDB_OPTS=R=0 TTY=/dev/ttyc" perl -d myprogram
  492.  
  493.                              may be useful for debugging a program which uses
  494.                              Term::ReadLine itself.  Do not forget detach
  495.                              shell from the TTY in the window which
  496.                              corresponds to /_d_e_v/_t_t_y_c, say, by issuing a
  497.                              command like
  498.  
  499.                                $ sleep 1000000
  500.  
  501.                              See the section on _D_e_b_u_g_g_e_r _I_n_t_e_r_n_a_l_s below for
  502.                              more details.
  503.  
  504.      < [ command ]
  505.                  Set an action (Perl command) to happen before every debugger
  506.                  prompt.  A multi-line command may be entered by backslashing
  507.                  the newlines.  If command is missing, resets the list of
  508.                  actions.
  509.  
  510.      << command  Add an action (Perl command) to happen before every debugger
  511.                  prompt.  A multi-line command may be entered by backslashing
  512.                  the newlines.
  513.  
  514.      > command   Set an action (Perl command) to happen after the prompt when
  515.                  you've just given a command to return to executing the
  516.                  script.  A multi-line command may be entered by backslashing
  517.                  the newlines.  If command is missing, resets the list of
  518.                  actions.
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.                                                                         PPPPaaaaggggeeee 8888
  526.  
  527.  
  528.  
  529.  
  530.  
  531.  
  532. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  533.  
  534.  
  535.  
  536.      >> command  Adds an action (Perl command) to happen after the prompt when
  537.                  you've just given a command to return to executing the
  538.                  script.  A multi-line command may be entered by backslashing
  539.                  the newlines.
  540.  
  541.      { [ command ]
  542.                  Set an action (debugger command) to happen before every
  543.                  debugger prompt.  A multi-line command may be entered by
  544.                  backslashing the newlines.  If command is missing, resets the
  545.                  list of actions.
  546.  
  547.      {{ command  Add an action (debugger command) to happen before every
  548.                  debugger prompt.  A multi-line command may be entered by
  549.                  backslashing the newlines.
  550.  
  551.      ! number    Redo a previous command (default previous command).
  552.  
  553.      ! -number   Redo number'th-to-last command.
  554.  
  555.      ! pattern   Redo last command that started with pattern.  See O
  556.                  recallCommand, too.
  557.  
  558.      !! cmd      Run cmd in a subprocess (reads from DB::IN, writes to
  559.                  DB::OUT) See O shellBang too.
  560.  
  561.      H -number   Display last n commands.  Only commands longer than one
  562.                  character are listed.  If number is omitted, lists them all.
  563.  
  564.      q or ^D     Quit.  ("quit" doesn't work for this.)  This is the only
  565.                  supported way to exit the debugger, though typing exit twice
  566.                  may do it too.
  567.  
  568.                  Set an Option inhibit_exit to 0 if you want to be able to
  569.                  _s_t_e_p _o_f_f the end the script.  You may also need to set
  570.                  $finished to 0 at some moment if you want to step through
  571.                  global destruction.
  572.  
  573.      R           Restart the debugger by eeeexxxxeeeeccccing a new session.  It tries to
  574.                  maintain your history across this, but internal settings and
  575.                  command line options may be lost.
  576.  
  577.                  Currently the following setting are preserved: history,
  578.                  breakpoints, actions, debugger Options, and the following
  579.                  command line options: ----wwww, ----IIII, and ----eeee.
  580.  
  581.      |dbcmd      Run debugger command, piping DB::OUT to current pager.
  582.  
  583.      ||dbcmd     Same as |dbcmd but DB::OUT is temporarily sssseeeelllleeeecccctttted as well.
  584.                  Often used with commands that would otherwise produce long
  585.                  output, such as
  586.  
  587.                      |V main
  588.  
  589.  
  590.  
  591.                                                                         PPPPaaaaggggeeee 9999
  592.  
  593.  
  594.  
  595.  
  596.  
  597.  
  598. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  599.  
  600.  
  601.  
  602.      = [alias value]
  603.                  Define a command alias, like
  604.  
  605.                      = quit q
  606.  
  607.                  or list current aliases.
  608.  
  609.      command     Execute command as a Perl statement.  A missing semicolon
  610.                  will be supplied.
  611.  
  612.      m expr      The expression is evaluated, and the methods which may be
  613.                  applied to the result are listed.
  614.  
  615.      m package   The methods which may be applied to objects in the package
  616.                  are listed.
  617.  
  618.      DDDDeeeebbbbuuuuggggggggeeeerrrr iiiinnnnppppuuuutttt////oooouuuuttttppppuuuutttt
  619.  
  620.      Prompt  The debugger prompt is something like
  621.  
  622.                  DB<8>
  623.  
  624.              or even
  625.  
  626.                  DB<<17>>
  627.  
  628.              where that number is the command number, which you'd use to
  629.              access with the builtin ccccsssshhhh-like history mechanism, e.g., !17
  630.              would repeat command number 17.  The number of angle brackets
  631.              indicates the depth of the debugger.  You could get more than one
  632.              set of brackets, for example, if you'd already at a breakpoint
  633.              and then printed out the result of a function call that itself
  634.              also has a breakpoint, or you step into an expression via s/n/t
  635.              expression command.
  636.  
  637.      Multiline commands
  638.              If you want to enter a multi-line command, such as a subroutine
  639.              definition with several statements, or a format, you may escape
  640.              the newline that would normally end the debugger command with a
  641.              backslash.  Here's an example:
  642.  
  643.                    DB<1> for (1..4) {         \
  644.                    cont:     print "ok\n";   \
  645.                    cont: }
  646.                    ok
  647.                    ok
  648.                    ok
  649.                    ok
  650.  
  651.              Note that this business of escaping a newline is specific to
  652.              interactive commands typed into the debugger.
  653.  
  654.  
  655.  
  656.  
  657.                                                                        PPPPaaaaggggeeee 11110000
  658.  
  659.  
  660.  
  661.  
  662.  
  663.  
  664. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  665.  
  666.  
  667.  
  668.      Stack backtrace
  669.              Here's an example of what a stack backtrace via T command might
  670.              look like:
  671.  
  672.                  $ = main::infested called from file `Ambulation.pm' line 10
  673.                  @ = Ambulation::legs(1, 2, 3, 4) called from file `camel_flea' line 7
  674.                  $ = main::pests('bactrian', 4) called from file `camel_flea' line 4
  675.  
  676.              The left-hand character up there tells whether the function was
  677.              called in a scalar or list context (we bet you can tell which is
  678.              which).  What that says is that you were in the function
  679.              main::infested when you ran the stack dump, and that it was
  680.              called in a scalar context from line 10 of the file
  681.              _A_m_b_u_l_a_t_i_o_n._p_m, but without any arguments at all, meaning it was
  682.              called as &infested.  The next stack frame shows that the
  683.              function Ambulation::legs was called in a list context from the
  684.              _c_a_m_e_l__f_l_e_a file with four arguments.  The last stack frame shows
  685.              that main::pests was called in a scalar context, also from
  686.              _c_a_m_e_l__f_l_e_a, but from line 4.
  687.  
  688.              Note that if you execute T command from inside an active use
  689.              statement, the backtrace will contain both require frame and an
  690.              eval) frame.
  691.  
  692.      Listing Listing given via different flavors of l command looks like this:
  693.  
  694.                  DB<<13>> l
  695.                101:                @i{@i} = ();
  696.                102:b               @isa{@i,$pack} = ()
  697.                103                     if(exists $i{$prevpack} || exists $isa{$pack});
  698.                104             }
  699.                105
  700.                106             next
  701.                107==>              if(exists $isa{$pack});
  702.                108
  703.                109:a           if ($extra-- > 0) {
  704.                110:                %isa = ($pack,1);
  705.  
  706.              Note that the breakable lines are marked with :, lines with
  707.              breakpoints are marked by b, with actions by a, and the next
  708.              executed line is marked by ==>.
  709.  
  710.      Frame listing
  711.              When frame option is set, debugger would print entered (and
  712.              optionally exited) subroutines in different styles.
  713.  
  714.              What follows is the start of the listing of
  715.  
  716.                env "PERLDB_OPTS=f=n N" perl -d -V
  717.  
  718.              for different values of n:
  719.  
  720.  
  721.  
  722.  
  723.                                                                        PPPPaaaaggggeeee 11111111
  724.  
  725.  
  726.  
  727.  
  728.  
  729.  
  730. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  731.  
  732.  
  733.  
  734.      1
  735.  
  736.                    entering main::BEGIN
  737.                     entering Config::BEGIN
  738.                      Package lib/Exporter.pm.
  739.                      Package lib/Carp.pm.
  740.                     Package lib/Config.pm.
  741.                     entering Config::TIEHASH
  742.                     entering Exporter::import
  743.                      entering Exporter::export
  744.                    entering Config::myconfig
  745.                     entering Config::FETCH
  746.                     entering Config::FETCH
  747.                     entering Config::FETCH
  748.                     entering Config::FETCH
  749.  
  750.  
  751.      2
  752.  
  753.                    entering main::BEGIN
  754.                     entering Config::BEGIN
  755.                      Package lib/Exporter.pm.
  756.                      Package lib/Carp.pm.
  757.                     exited Config::BEGIN
  758.                     Package lib/Config.pm.
  759.                     entering Config::TIEHASH
  760.                     exited Config::TIEHASH
  761.                     entering Exporter::import
  762.                      entering Exporter::export
  763.                      exited Exporter::export
  764.                     exited Exporter::import
  765.                    exited main::BEGIN
  766.                    entering Config::myconfig
  767.                     entering Config::FETCH
  768.                     exited Config::FETCH
  769.                     entering Config::FETCH
  770.                     exited Config::FETCH
  771.                     entering Config::FETCH
  772.  
  773.  
  774.      4
  775.  
  776.  
  777.  
  778.  
  779.  
  780.  
  781.  
  782.  
  783.  
  784.  
  785.  
  786.  
  787.  
  788.  
  789.                                                                        PPPPaaaaggggeeee 11112222
  790.  
  791.  
  792.  
  793.  
  794.  
  795.  
  796. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  797.  
  798.  
  799.  
  800.                    in  $=main::BEGIN() from /dev/nul:0
  801.                     in  $=Config::BEGIN() from lib/Config.pm:2
  802.                      Package lib/Exporter.pm.
  803.                      Package lib/Carp.pm.
  804.                     Package lib/Config.pm.
  805.                     in  $=Config::TIEHASH('Config') from lib/Config.pm:644
  806.                     in  $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
  807.                      in  $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from li
  808.                    in  @=Config::myconfig() from /dev/nul:0
  809.                     in  $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574
  810.                     in  $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574
  811.                     in  $=Config::FETCH(ref(Config), 'PATCHLEVEL') from lib/Config.pm:574
  812.                     in  $=Config::FETCH(ref(Config), 'SUBVERSION') from lib/Config.pm:574
  813.                     in  $=Config::FETCH(ref(Config), 'osname') from lib/Config.pm:574
  814.                     in  $=Config::FETCH(ref(Config), 'osvers') from lib/Config.pm:574
  815.  
  816.  
  817.      6
  818.  
  819.                    in  $=main::BEGIN() from /dev/nul:0
  820.                     in  $=Config::BEGIN() from lib/Config.pm:2
  821.                      Package lib/Exporter.pm.
  822.                      Package lib/Carp.pm.
  823.                     out $=Config::BEGIN() from lib/Config.pm:0
  824.                     Package lib/Config.pm.
  825.                     in  $=Config::TIEHASH('Config') from lib/Config.pm:644
  826.                     out $=Config::TIEHASH('Config') from lib/Config.pm:644
  827.                     in  $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
  828.                      in  $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/
  829.                      out $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/
  830.                     out $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
  831.                    out $=main::BEGIN() from /dev/nul:0
  832.                    in  @=Config::myconfig() from /dev/nul:0
  833.                     in  $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574
  834.                     out $=Config::FETCH(ref(Config), 'package') from lib/Config.pm:574
  835.                     in  $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574
  836.                     out $=Config::FETCH(ref(Config), 'baserev') from lib/Config.pm:574
  837.                     in  $=Config::FETCH(ref(Config), 'PATCHLEVEL') from lib/Config.pm:574
  838.                     out $=Config::FETCH(ref(Config), 'PATCHLEVEL') from lib/Config.pm:574
  839.                     in  $=Config::FETCH(ref(Config), 'SUBVERSION') from lib/Config.pm:574
  840.  
  841.  
  842.      14
  843.  
  844.  
  845.  
  846.  
  847.  
  848.  
  849.  
  850.  
  851.  
  852.  
  853.  
  854.  
  855.                                                                        PPPPaaaaggggeeee 11113333
  856.  
  857.  
  858.  
  859.  
  860.  
  861.  
  862. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  863.  
  864.  
  865.  
  866.                    in  $=main::BEGIN() from /dev/nul:0
  867.                     in  $=Config::BEGIN() from lib/Config.pm:2
  868.                      Package lib/Exporter.pm.
  869.                      Package lib/Carp.pm.
  870.                     out $=Config::BEGIN() from lib/Config.pm:0
  871.                     Package lib/Config.pm.
  872.                     in  $=Config::TIEHASH('Config') from lib/Config.pm:644
  873.                     out $=Config::TIEHASH('Config') from lib/Config.pm:644
  874.                     in  $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
  875.                      in  $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/E
  876.                      out $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/E
  877.                     out $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/nul:0
  878.                    out $=main::BEGIN() from /dev/nul:0
  879.                    in  @=Config::myconfig() from /dev/nul:0
  880.                     in  $=Config::FETCH('Config=HASH(0x1aa444)', 'package') from lib/Config.pm:574
  881.                     out $=Config::FETCH('Config=HASH(0x1aa444)', 'package') from lib/Config.pm:574
  882.                     in  $=Config::FETCH('Config=HASH(0x1aa444)', 'baserev') from lib/Config.pm:574
  883.                     out $=Config::FETCH('Config=HASH(0x1aa444)', 'baserev') from lib/Config.pm:574
  884.  
  885.  
  886.      30
  887.  
  888.                    in  $=CODE(0x15eca4)() from /dev/null:0
  889.                     in  $=CODE(0x182528)() from lib/Config.pm:2
  890.                      Package lib/Exporter.pm.
  891.                     out $=CODE(0x182528)() from lib/Config.pm:0
  892.                     scalar context return from CODE(0x182528): undef
  893.                     Package lib/Config.pm.
  894.                     in  $=Config::TIEHASH('Config') from lib/Config.pm:628
  895.                     out $=Config::TIEHASH('Config') from lib/Config.pm:628
  896.                     scalar context return from Config::TIEHASH:   empty hash
  897.                     in  $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
  898.                      in  $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/Exporter.pm:171
  899.                      out $=Exporter::export('Config', 'main', 'myconfig', 'config_vars') from lib/Exporter.pm:171
  900.                      scalar context return from Exporter::export: ''
  901.                     out $=Exporter::import('Config', 'myconfig', 'config_vars') from /dev/null:0
  902.                     scalar context return from Exporter::import: ''
  903.  
  904.  
  905.                  In all the cases indentation of lines shows the call tree, if
  906.                  bit 2 of frame is set, then a line is printed on exit from a
  907.                  subroutine as well, if bit 4 is set, then the arguments are
  908.                  printed as well as the caller info, if bit 8 is set, the
  909.                  arguments are printed even if they are tied or references, if
  910.                  bit 16 is set, the return value is printed as well.
  911.  
  912.                  When a package is compiled, a line like this
  913.  
  914.                      Package lib/Carp.pm.
  915.  
  916.                  is printed with proper indentation.
  917.  
  918.  
  919.  
  920.  
  921.                                                                        PPPPaaaaggggeeee 11114444
  922.  
  923.  
  924.  
  925.  
  926.  
  927.  
  928. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  929.  
  930.  
  931.  
  932.      DDDDeeeebbbbuuuuggggggggiiiinnnngggg ccccoooommmmppppiiiilllleeee----ttttiiiimmmmeeee ssssttttaaaatttteeeemmmmeeeennnnttttssss
  933.  
  934.      If you have any compile-time executable statements (code within a BEGIN
  935.      block or a use statement), these will NOT be stopped by debugger,
  936.      although requires will (and compile-time statements can be traced with
  937.      AutoTrace option set in PERLDB_OPTS).  From your own Perl code, however,
  938.      you can transfer control back to the debugger using the following
  939.      statement, which is harmless if the debugger is not running:
  940.  
  941.          $DB::single = 1;
  942.  
  943.      If you set $DB::single to the value 2, it's equivalent to having just
  944.      typed the n command, whereas a value of 1 means the s command.  The
  945.      $DB::trace  variable should be set to 1 to simulate having typed the t
  946.      command.
  947.  
  948.      Another way to debug compile-time code is to start debugger, set a
  949.      breakpoint on _l_o_a_d of some module thusly
  950.  
  951.          DB<7> b load f:/perllib/lib/Carp.pm
  952.        Will stop on load of `f:/perllib/lib/Carp.pm'.
  953.  
  954.      and restart debugger by R command (if possible).  One can use b compile
  955.      subname for the same purpose.
  956.  
  957.      DDDDeeeebbbbuuuuggggggggeeeerrrr CCCCuuuussssttttoooommmmiiiizzzzaaaattttiiiioooonnnn
  958.  
  959.      Most probably you do not want to modify the debugger, it contains enough
  960.      hooks to satisfy most needs.  You may change the behaviour of debugger
  961.      from the debugger itself, using Options, from the command line via
  962.      PERLDB_OPTS environment variable, and from _c_u_s_t_o_m_i_z_a_t_i_o_n _f_i_l_e_s.
  963.  
  964.      You can do some customization by setting up a ._p_e_r_l_d_b file which contains
  965.      initialization code.  For instance, you could make aliases like these
  966.      (the last one is one people expect to be there):
  967.  
  968.          $DB::alias{'len'}  = 's/^len(.*)/p length($1)/';
  969.          $DB::alias{'stop'} = 's/^stop (at|in)/b/';
  970.          $DB::alias{'ps'}   = 's/^ps\b/p scalar /';
  971.          $DB::alias{'quit'} = 's/^quit(\s*)/exit\$/';
  972.  
  973.      One changes options from ._p_e_r_l_d_b file via calls like this one;
  974.  
  975.          parse_options("NonStop=1 LineInfo=db.out AutoTrace=1 frame=2");
  976.  
  977.      (the code is executed in the package DB).  Note that ._p_e_r_l_d_b is processed
  978.      before processing PERLDB_OPTS.  If ._p_e_r_l_d_b defines the subroutine
  979.      afterinit, it is called after all the debugger initialization ends.
  980.      ._p_e_r_l_d_b may be contained in the current directory, or in the LOGDIR/HOME
  981.      directory.
  982.  
  983.  
  984.  
  985.  
  986.  
  987.                                                                        PPPPaaaaggggeeee 11115555
  988.  
  989.  
  990.  
  991.  
  992.  
  993.  
  994. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  995.  
  996.  
  997.  
  998.      If you want to modify the debugger, copy _p_e_r_l_5_d_b._p_l from the Perl library
  999.      to another name and modify it as necessary.  You'll also want to set your
  1000.      PERL5DB environment variable to say something like this:
  1001.  
  1002.          BEGIN { require "myperl5db.pl" }
  1003.  
  1004.      As the last resort, one can use PERL5DB to customize debugger by directly
  1005.      setting internal variables or calling debugger functions.
  1006.  
  1007.      RRRReeeeaaaaddddlllliiiinnnneeee SSSSuuuuppppppppoooorrrrtttt
  1008.  
  1009.      As shipped, the only command line history supplied is a simplistic one
  1010.      that checks for leading exclamation points.  However, if you install the
  1011.      Term::ReadKey and Term::ReadLine modules from CPAN, you will have full
  1012.      editing capabilities much like GNU _r_e_a_d_l_i_n_e(3) provides.  Look for these
  1013.      in the _m_o_d_u_l_e_s/_b_y-_m_o_d_u_l_e/_T_e_r_m directory on CPAN.
  1014.  
  1015.      A rudimentary command line completion is also available.  Unfortunately,
  1016.      the names of lexical variables are not available for completion.
  1017.  
  1018.      EEEEddddiiiittttoooorrrr SSSSuuuuppppppppoooorrrrtttt ffffoooorrrr DDDDeeeebbbbuuuuggggggggiiiinnnngggg
  1019.  
  1020.      If you have GNU eeeemmmmaaaaccccssss installed on your system, it can interact with the
  1021.      Perl debugger to provide an integrated software development environment
  1022.      reminiscent of its interactions with C debuggers.
  1023.  
  1024.      Perl is also delivered with a start file for making eeeemmmmaaaaccccssss act like a
  1025.      syntax-directed editor that understands (some of) Perl's syntax.  Look in
  1026.      the _e_m_a_c_s directory of the Perl source distribution.
  1027.  
  1028.      (Historically, a similar setup for interacting with vvvviiii and the X11 window
  1029.      system had also been available, but at the time of this writing, no
  1030.      debugger support for vvvviiii currently exists.)
  1031.  
  1032.      TTTThhhheeee PPPPeeeerrrrllll PPPPrrrrooooffffiiiilllleeeerrrr
  1033.  
  1034.      If you wish to supply an alternative debugger for Perl to run, just
  1035.      invoke your script with a colon and a package argument given to the ----dddd
  1036.      flag.  One of the most popular alternative debuggers for Perl is DDDDPPPPrrrrooooffff,
  1037.      the Perl profiler.   As of this writing, DDDDPPPPrrrrooooffff is not included with the
  1038.      standard Perl distribution, but it is expected to be included soon, for
  1039.      certain values of "soon".
  1040.  
  1041.      Meanwhile, you can fetch the Devel::Dprof module from CPAN.  Assuming
  1042.      it's properly installed on your system, to profile your Perl program in
  1043.      the file _m_y_c_o_d_e._p_l, just type:
  1044.  
  1045.          perl -d:DProf mycode.pl
  1046.  
  1047.      When the script terminates the profiler will dump the profile information
  1048.      to a file called _t_m_o_n._o_u_t.  A tool like ddddpppprrrrooooffffpppppppp (also supplied with the
  1049.      Devel::DProf package) can be used to interpret the information which is
  1050.  
  1051.  
  1052.  
  1053.                                                                        PPPPaaaaggggeeee 11116666
  1054.  
  1055.  
  1056.  
  1057.  
  1058.  
  1059.  
  1060. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  1061.  
  1062.  
  1063.  
  1064.      in that profile.
  1065.  
  1066.      DDDDeeeebbbbuuuuggggggggeeeerrrr ssssuuuuppppppppoooorrrrtttt iiiinnnn ppppeeeerrrrllll
  1067.  
  1068.      When you call the ccccaaaalllllllleeeerrrr function (see the caller entry in the _p_e_r_l_f_u_n_c
  1069.      manpage) from the package DB, Perl sets the array @DB::args to contain
  1070.      the arguments the corresponding stack frame was called with.
  1071.  
  1072.      If perl is run with ----dddd option, the following additional features are
  1073.      enabled (cf. the section on $^_P in the _p_e_r_l_v_a_r manpage):
  1074.  
  1075.      +o    Perl inserts the contents of $ENV{PERL5DB} (or BEGIN {require
  1076.           'perl5db.pl'} if not present) before the first line of the
  1077.           application.
  1078.  
  1079.      +o    The array @{"_<$filename"} is the line-by-line contents of $filename
  1080.           for all the compiled files.  Same for evaled strings which contain
  1081.           subroutines, or which are currently executed.  The $filename for
  1082.           evaled strings looks like (eval 34).
  1083.  
  1084.      +o    The hash %{"_<$filename"} contains breakpoints and action (it is
  1085.           keyed by line number), and individual entries are settable (as
  1086.           opposed to the whole hash).  Only true/false is important to Perl,
  1087.           though the values used by _p_e_r_l_5_d_b._p_l have the form
  1088.           "$break_condition\0$action".  Values are magical in numeric context:
  1089.           they are zeros if the line is not breakable.
  1090.  
  1091.           Same for evaluated strings which contain subroutines, or which are
  1092.           currently executed.  The $filename for evaled strings looks like
  1093.           (eval 34).
  1094.  
  1095.      +o    The scalar ${"_<$filename"} contains "_<$filename".  Same for
  1096.           evaluated strings which contain subroutines, or which are currently
  1097.           executed.  The $filename for evaled strings looks like (eval 34).
  1098.  
  1099.      +o    After each required file is compiled, but before it is executed,
  1100.           DB::postponed(*{"_<$filename"}) is called (if subroutine
  1101.           DB::postponed exists).  Here the $filename is the expanded name of
  1102.           the required file (as found in values of %INC).
  1103.  
  1104.      +o    After each subroutine subname is compiled existence of
  1105.           $DB::postponed{subname} is checked.  If this key exists,
  1106.           DB::postponed(subname) is called (if subroutine DB::postponed
  1107.           exists).
  1108.  
  1109.      +o    A hash %DB::sub is maintained, with keys being subroutine names,
  1110.           values having the form filename:startline-endline.  filename has the
  1111.           form (eval 31) for subroutines defined inside evals.
  1112.  
  1113.      +o    When execution of the application reaches a place that can have a
  1114.           breakpoint, a call to DB::DB() is performed if any one of variables
  1115.           $DB::trace, $DB::single, or $DB::signal is true. (Note that these
  1116.  
  1117.  
  1118.  
  1119.                                                                        PPPPaaaaggggeeee 11117777
  1120.  
  1121.  
  1122.  
  1123.  
  1124.  
  1125.  
  1126. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  1127.  
  1128.  
  1129.  
  1130.           variables are not localizable.) This feature is disabled when the
  1131.           control is inside DB::DB() or functions called from it (unless $^D &
  1132.           (1<<30)).
  1133.  
  1134.      +o    When execution of the application reaches a subroutine call, a call
  1135.           to &DB::sub(_a_r_g_s) is performed instead, with $DB::sub being the name
  1136.           of the called subroutine. (Unless the subroutine is compiled in the
  1137.           package DB.)
  1138.  
  1139.      Note that if &DB::sub needs some external data to be setup for it to
  1140.      work, no subroutine call is possible until this is done.  For the
  1141.      standard debugger $DB::deep (how many levels of recursion deep into the
  1142.      debugger you can go before a mandatory break) gives an example of such a
  1143.      dependency.
  1144.  
  1145.      The minimal working debugger consists of one line
  1146.  
  1147.        sub DB::DB {}
  1148.  
  1149.      which is quite handy as contents of PERL5DB environment variable:
  1150.  
  1151.        env "PERL5DB=sub DB::DB {}" perl -d your-script
  1152.  
  1153.      Another (a little bit more useful) minimal debugger can be created with
  1154.      the only line being
  1155.  
  1156.        sub DB::DB {print ++$i; scalar <STDIN>}
  1157.  
  1158.      This debugger would print the sequential number of encountered statement,
  1159.      and would wait for your CR to continue.
  1160.  
  1161.      The following debugger is quite functional:
  1162.  
  1163.        {
  1164.          package DB;
  1165.          sub DB  {}
  1166.          sub sub {print ++$i, " $sub\n"; &$sub}
  1167.        }
  1168.  
  1169.      It prints the sequential number of subroutine call and the name of the
  1170.      called subroutine.  Note that &DB::sub should be compiled into the
  1171.      package DB.
  1172.  
  1173.      DDDDeeeebbbbuuuuggggggggeeeerrrr IIIInnnntttteeeerrrrnnnnaaaallllssss
  1174.  
  1175.      At the start, the debugger reads your rc file (./._p_e_r_l_d_b or ~/._p_e_r_l_d_b
  1176.      under Unix), which can set important options.  This file may define a
  1177.      subroutine &afterinit to be executed after the debugger is initialized.
  1178.  
  1179.      After the rc file is read, the debugger reads environment variable
  1180.      PERLDB_OPTS and parses it as a rest of O ... line in debugger prompt.
  1181.  
  1182.  
  1183.  
  1184.  
  1185.                                                                        PPPPaaaaggggeeee 11118888
  1186.  
  1187.  
  1188.  
  1189.  
  1190.  
  1191.  
  1192. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  1193.  
  1194.  
  1195.  
  1196.      It also maintains magical internal variables, such as @DB::dbline,
  1197.      %DB::dbline, which are aliases for @{"::_<current_file"}
  1198.      %{"::_<current_file"}.  Here current_file is the currently selected (with
  1199.      the debugger's f command, or by flow of execution) file.
  1200.  
  1201.      Some functions are provided to simplify customization.  See the section
  1202.      on _D_e_b_u_g_g_e_r _C_u_s_t_o_m_i_z_a_t_i_o_n for description of DB::parse_options(string).
  1203.      The function DB::dump_trace(skip[, count]) skips the specified number of
  1204.      frames, and returns a list containing info about the caller frames (all
  1205.      if count is missing).  Each entry is a hash with keys context ($ or @),
  1206.      sub (subroutine name, or info about eval), args (undef or a reference to
  1207.      an array), file, and line.
  1208.  
  1209.      The function DB::print_trace(FH, skip[, count[, short]]) prints formatted
  1210.      info about caller frames.  The last two functions may be convenient as
  1211.      arguments to <, << commands.
  1212.  
  1213.      OOOOtttthhhheeeerrrr rrrreeeessssoooouuuurrrrcccceeeessss
  1214.  
  1215.      You did try the ----wwww switch, didn't you?
  1216.  
  1217. BBBBUUUUGGGGSSSS
  1218.      You cannot get the stack frame information or otherwise debug functions
  1219.      that were not compiled by Perl, such as C or C++ extensions.
  1220.  
  1221.      If you alter your @_ arguments in a subroutine (such as with sssshhhhiiiifffftttt or
  1222.      ppppoooopppp, the stack backtrace will not show the original values.
  1223.  
  1224.  
  1225.  
  1226.  
  1227.  
  1228.  
  1229.  
  1230.  
  1231.  
  1232.  
  1233.  
  1234.  
  1235.  
  1236.  
  1237.  
  1238.  
  1239.  
  1240.  
  1241.  
  1242.  
  1243.  
  1244.  
  1245.  
  1246.  
  1247.  
  1248.  
  1249.  
  1250.  
  1251.                                                                        PPPPaaaaggggeeee 11119999
  1252.  
  1253.  
  1254.  
  1255.  
  1256.  
  1257.  
  1258. PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))                                                      PPPPEEEERRRRLLLLDDDDEEEEBBBBUUUUGGGG((((1111))))
  1259.  
  1260.  
  1261.  
  1262.  
  1263.  
  1264.  
  1265.  
  1266.  
  1267.  
  1268.  
  1269.  
  1270.  
  1271.  
  1272.  
  1273.  
  1274.  
  1275.  
  1276.  
  1277.  
  1278.  
  1279.  
  1280.  
  1281.  
  1282.  
  1283.  
  1284.  
  1285.  
  1286.  
  1287.  
  1288.  
  1289.  
  1290.  
  1291.  
  1292.  
  1293.  
  1294.  
  1295.  
  1296.  
  1297.  
  1298.  
  1299.  
  1300.  
  1301.  
  1302.  
  1303.  
  1304.  
  1305.  
  1306.  
  1307.  
  1308.  
  1309.  
  1310.  
  1311.  
  1312.  
  1313.  
  1314.                                                                        PPPPaaaaggggeeee 22220000
  1315.  
  1316.  
  1317.  
  1318.  
  1319.  
  1320.  
  1321.